package com.shop.cereshop.commons.enums.recommend;

import io.swagger.annotations.ApiModel;
import lombok.Getter;

@Getter
@ApiModel(value = "RecommendVisitEnum", description = "动态可见条件枚举")
public enum RecommendVisitEnum {
    
    PUBLIC(0, "公开"),
    PRIVATE(1, "私密"),
    PARTIAL(2, "部分可见")
    ;
    
    private final Integer code;
    private final String msg;
    
    RecommendVisitEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    
    public static String getMsgByCode(Integer code) {
        for (RecommendVisitEnum value : values()) {
            if (value.code.equals(code)) {
                return value.msg;
            }
        }
        return null;
    }

    public static Integer getCodeByMsg(String msg) {
        for (RecommendVisitEnum value : values()) {
            if (value.msg.equals(msg)) {
                return value.code;
            }
        }
        return -1;
    }
}
